package com.es.hr.shop;

import java.lang.reflect.Field;

import javax.servlet.http.HttpServletRequest;

import com.es.business.area.AreaBean;
import com.es.business.area.AreaBiz;
import com.es.business.city.CityBean;
import com.es.business.city.CityBiz;
import com.es.business.citys.CitysBean;
import com.es.business.citys.CitysBiz;
import com.es.business.province.ProvinceBean;
import com.es.business.province.ProvinceBiz;
import com.es.hr.emp.EmpInfoBean;
import com.es.util.page.PageBean;
import com.opensymphony.webwork.interceptor.ServletRequestAware;
import com.opensymphony.xwork.ActionSupport;

public class ShopAddSearchPopupInitAction extends ActionSupport
implements ServletRequestAware{
	 HttpServletRequest request;

	public void setServletRequest(HttpServletRequest paramHttpServletRequest) {
		// TODO Auto-generated method stub
		request = paramHttpServletRequest;
	}
	
	public String execute() throws Exception{
		String result = "";
		ShopBiz shopBiz = new ShopBiz();
		
		String area_code = request.getParameter("emp_area_code");
		if(area_code == null) area_code = "";
		
		String shop_ctm_code = request.getParameter("shop_ctm_code");
		if(shop_ctm_code == null) shop_ctm_code = "";
		
		String province_code = request.getParameter("emp_province_code");
		if(province_code == null) province_code = "";
		
		String city_code = request.getParameter("emp_city_code");
		if(city_code == null) city_code = "";
		
		String hasRTM = request.getParameter("hasRTM");
		if(hasRTM == null) hasRTM = "N";
		
		String queryShopCode = request.getParameter("queryShopCode");
		String queryShopName = request.getParameter("queryShopName");
		
		String curpage = request.getParameter("curpage");
		if(curpage == null || curpage=="") curpage = "1";
		int curpag = Integer.parseInt(curpage);
		
		
		
		PageBean res = shopBiz.searchNotCTMShop("", "", "","","",shop_ctm_code, curpag,hasRTM);
		request.setAttribute("pageBean", res);
		request.setAttribute("areaList", new AreaBiz().getAreaList());
		request.setAttribute("shop_ctm_code", shop_ctm_code);
		request.setAttribute("emp_area_code", "");
		request.setAttribute("emp_province_code", "");
		request.setAttribute("emp_city_code", "");
		request.setAttribute("queryShopCode", "");
		request.setAttribute("queryShopName", "");
		request.setAttribute("hasRTM", hasRTM);
		result = "success";
		return result;
	}
	
	public ShopBean getShopBBean(HttpServletRequest request) throws SecurityException, ClassNotFoundException, IllegalArgumentException, IllegalAccessException{
		Field[] fds = Class.forName("com.es.hr.shop.ShopBean").getDeclaredFields();   
		ShopBean bean = new ShopBean();
		 
		  for(int i=0;i<fds.length;i++)   
		  {   
			  String d= fds[i].getName();
			  fds[i].set(bean, request.getParameter(d));
		  }
		  return bean;
	}
	 

}
